<script lang="ts">
import { defineComponent, h } from 'vue'

export default defineComponent({
  props: {
    type: {
      type: String,
      required: true
    }
  },
  setup(props, { slots }) {
    const getClass = () => {
      switch (props.type) {
        case 'success':
          return 'hightlight-state--success'
        case 'warning':
          return 'hightlight-state--warning'
        default:
          return 'hightlight-state--danger'
      }
    }

    return () =>
      h('div', { class: ['hightlight-state', getClass()] }, [
        h('div', { class: 'highlight-tag' }),
        slots.text ? slots.text() : ''
      ])
  }
})
</script>

<style scoped lang="scss">
.hightlight-state {
  display: flex;
  align-items: center;
  margin-top: 16px;
  .highlight-tag {
    width: 6px;
    height: 6px;
    border-radius: 50%;
  }
  :slotted(span) {
    font-size: 14px;
    font-family: PingFang SC;
    line-height: 20px;
    margin-left: 5px;
  }
}
.hightlight-state--danger {
  .highlight-tag {
    background: #f56c6c;
  }
  :deep(span) {
    font-size: 14px;
    font-family: PingFang SC;
    line-height: 20px;
    margin-left: 5px;
    color: #f56c6c;
  }
}
.hightlight-state--success {
  .highlight-tag {
    background: #00a870;
  }
  :deep(span) {
    font-size: 14px;
    font-family: PingFang SC;
    line-height: 20px;
    margin-left: 5px;
    color: #00a870;
  }
}
.hightlight-state--danger {
  .highlight-tag {
    background: #ee8b3f;
  }
  :deep(span) {
    font-size: 14px;
    font-family: PingFang SC;
    line-height: 20px;
    margin-left: 5px;
    color: #ee8b3f;
  }
}
</style>
